package com.pachong.android.frameworkbase.customviews;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.RadioButton;

/**
 * 分为左/中/右 三个部分
 *
 * @author Veivei Peng
 */
public class TestView extends RadioButton {

    public TestView(Context context) {
        this(context, null);
    }

    public TestView(Context context, AttributeSet attrs) {
        super(context, attrs);

    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        drawPoint(canvas);
    }

    private void drawPoint(Canvas canvas) {
        Paint p = new Paint();
        p.setColor(Color.RED);// 设置红色
        p.setAntiAlias(true);// 设置画笔的锯齿效果。 true是去除，大家一看效果就明白了

        canvas.drawLine(0, 05, 10, 10, p);
        canvas.drawRect(0, 0, 20, 20, p);
        canvas.drawText("ddddddd", 0, 0, p);
        canvas.drawCircle(20, 20, 8, p);// 小圆
    }


    public static int dip2px(Context context, float dpValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5f);
    }


}
